﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TestWeb.Models.ViewModel>" %>
<script src="../../../Scripts/ckeditor/ckeditor.js" type="text/javascript"></script>
<script src="../../../Scripts/jquery.filestyle.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        // Create new CKEDITOR
        CKEDITOR.replace('NoiDung',
        {
            height: "300", 
            width: "920",
            language: "en"
        });
        // For Upload file
        $("input.file_1").filestyle({
            image: '<%= ResolveUrl("../../../Content/AdminImages/forms/upload_file.gif")%>',
            imageheight: 29,
            imagewidth: 78,
            width: 300
        });
    });

    function validateTinTuc() {
        var tieude = document.getElementsByName("TieuDe").item(0);
        if (tieude.value == "") {
            $(".red-left").text('The input TieuDe is empty');
            $("#message-red").fadeIn('fast').delay(<%= WebConfiguration.Instance.AlertTime %>).fadeOut('slow'); 
            return false;
        }
        var noidung = CKEDITOR.instances.NoiDung.getData();
        if (noidung == "") {
            $(".red-left").text('The input NoiDung is empty');
            $("#message-red").fadeIn('fast').delay(<%= WebConfiguration.Instance.AlertTime %>).fadeOut('slow');
            return false;
        }
        return true;
    }
</script>

<!-- start table-content  -->
<div id="table-content">
    <!--  start message-red -->
    <div id="message-red">
	    <table border="0" width="100%" cellpadding="0" cellspacing="0">
		    <tr>
			    <td class="red-left">Error message</td>
		    </tr>
	    </table>
    </div>
    <!--  end message-red -->

    <!--  start message-blue -->
	<div id="message-blue">
		<table border="0" width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<td class="blue-left">Information message</td>
			</tr>
		</table>
	</div>
    <!--  end message-blue -->

    <script type="text/javascript">
        <% if (ViewData["Result"] != null)
           { 
                if(bool.Parse(ViewData["Result"].ToString()))
                {%>
                    $(".blue-left").text('<%= ViewData["MsgTxt"].ToString() %>');
                    $("#message-blue").fadeIn('fast').delay(<%= WebConfiguration.Instance.InfoTime %>).fadeOut('slow'); 
             <% }else
                { %>
                    $(".red-left").text('<%= ViewData["MsgTxt"].ToString() %>');
                    $("#message-red").fadeIn('fast').delay(<%= WebConfiguration.Instance.AlertTime %>).fadeOut('slow'); 
             <% } %>   
	    <% } %>
    </script>

    <% using (Html.BeginForm("InsertTinTuc", "Admin", FormMethod.Post, new { id = "MySubmitForm", enctype = "multipart/form-data", onsubmit = "return validateTinTuc();" }))
    { %>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr valign="top">
            <td>
                <!-- start id-form -->
                <table border="0" cellpadding="0" cellspacing="0" id="id-form">
                    <tr>
                        <th valign="top" style="padding-top: 2px;">
                            TieuDe:
                        </th>
                        <td>
                            <input type="text" name="TieuDe" class="inp-form" />
                        </td>
                        <td>
                        </td>
                    </tr>  
                    <tr>
                        <th valign="top" style="padding-top: 2px;">
                            NoiDung:
                        </th>
                        <td>
                            <%= Html.TextArea("NoiDung")%>
                        </td>
                        <td>
                        </td>
                    </tr>  
                    <tr>
	                    <th>HinhMinhHoa:</th>
	                    <td><input type="file" name="HinhMinhHoa" class="file_1" /></td>
	                </tr> 
                    <tr>
                        <th>
                            &nbsp;
                        </th>
                        <td valign="top">
                            <input type="hidden" name="IDLoaiTinTuc" value="<%= Model.LoaiTinTucs[0].ID %>" />
                            <input type="hidden" name="IDNguoiDung" value="<%= Membership.GetUser( Page.User.Identity.Name).ProviderUserKey %>" />
                            <input type="submit" value="" class="form-submit" />
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
                <!-- end id-form  -->
            </td>
        </tr>
    </table>
    <% } %>
</div>